//
// Created on 2024/11/28.
//
// Node APIs are not fully supported. To solve the compilation error of the interface cannot be found,
// please include "napi/native_api.h".

#ifndef DCAUTOTEST_PLUGINWINDOWRENDER_H
#define DCAUTOTEST_PLUGINWINDOWRENDER_H
#include <ace/xcomponent/native_interface_xcomponent.h>
#include <cstdint>
#include <native_window/external_window.h>
#include <string>

class PluginWindowRender {
private:
    int viewWidth;                  // 控件宽度
    int viewHeight;                 // 控件高度
    OHNativeWindow *mSurfaceWindow; // 当前传递进来的surfaceWindow窗口
    int mSurfaceTransformState;
//     EGLDisplay eglDisplay;          // egl的预览窗口
//     EGLSurface eglSurface;          // egl绘制的surface
//     EGLContext eglContext;          // egl的context
//     GLuint eglProgram;              // 着色器
//     GLuint eglTextures;             // 纹理id
    std::string mId; // 当前的surface对应的id

    void registerComponent(OH_NativeXComponent *nativeXComponent); // 注册监听
    static void onSurfaceCreated(OH_NativeXComponent *component, void *window);
    static void onSurfaceChanged(OH_NativeXComponent *component, void *window);
    static void onSurfaceDestroyed(OH_NativeXComponent *component, void *window);
    void initNativeWindow(void *window);
    bool initWindowOrientation();
public:
    static OH_NativeXComponent_Callback m_callback;
    PluginWindowRender(std::string id, OH_NativeXComponent *nativeXComponent);
    ~PluginWindowRender();
    bool drawFrame(uint8_t *data, size_t dataSize, int w, int h);
    void initSize(int width, int height);
    bool setSurfaceTransformState(int transformState);
};
#endif // DCAUTOTEST_PLUGINWINDOWRENDER_H
